package com.more.db.core;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName DatabaseContextHolder
 * @Description TODO
 * @Author yyliu
 * @Date 2018/12/10 16:03
 * @Version 1.0
 **/
public class DatabaseContextHolder {

    private static final ThreadLocal<String> contextHolder = new ThreadLocal<>();

    private static final Map<String, String> CORP_DB_NAME_MAP  = new HashMap<>();

    public static void setDatabaseType(String corpCode) {

        contextHolder.set(CORP_DB_NAME_MAP.get(corpCode));
    }

    public static String getDatabaseType() {
        return contextHolder.get();
    }

    public static void setCorpDbNameMap(String corpCode, String dbName) {
        CORP_DB_NAME_MAP.put(corpCode, dbName);
    }

}
